package com.nstar.splus.model
{
	import com.nstar.splus.msgitem.MicroMsgCommentItem;
	
	import mx.collections.ArrayCollection;
	
	/**
	 * 微博消息对象之缓存
	 * 2010.9.10
	 */ 
	public class MicroMsgCommentItemCache extends Object
	{
		public static var cacheSize:int = 0;
		public static var cache : ArrayCollection = new ArrayCollection();
		
		public function MicroMsgCommentItemCache()
		{
			//TODO: implement function
			trace("MicroMsgCommentItemCache constructor!");
			super();
			for (var i:int = 0;i<cacheSize;i++){
				cache.addItem(new MicroMsgCommentItem());
			}
		}
		
		//从缓存中获取一个对象
		public static function getMicroMsgCommentItem():Object{
			var msgItem : MicroMsgCommentItem = null;
			if(cache.length<=0){
				msgItem = new MicroMsgCommentItem();
				trace("new getMicroMsgCommentItem()");
			}else{
				msgItem = cache.removeItemAt(0) as MicroMsgCommentItem;
				trace("get from cache");
			}
			
			return msgItem;
		}
		
		//将不用的对象放到缓存中
		public static function setMicroMsgCommentItem(msgItem:Object):void{
			cache.addItem(msgItem);
			trace("add to cache");
		}
		
	}
}